<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>管理员</title>
    <link href="__STATIC__/admin/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="__STATIC__/admin/css/style.css" />
    <link href="__STATIC__/admin/assets/css/codemirror.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/ace.min.css" />
    <link rel="stylesheet" href="__STATIC__/admin/font/css/font-awesome.min.css" />
    <!--[if lte IE 8]>
		  <link rel="stylesheet" href="__STATIC__/admin/assets/css/ace-ie.min.css" />
		<![endif]-->
    <script src="__STATIC__/admin/js/jquery-1.9.1.min.js"></script>
    <script src="__STATIC__/admin/assets/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="__STATIC__/admin/Widget/Validform/5.3.2/Validform.min.js"></script>
    <script src="__STATIC__/admin/assets/js/typeahead-bs2.min.js"></script>
    <script src="__STATIC__/admin/assets/js/jquery.dataTables.min.js"></script>
    <script src="__STATIC__/admin/assets/js/jquery.dataTables.bootstrap.js"></script>
    <script src="__STATIC__/admin/assets/layer/layer.js" type="text/javascript"></script>
    <script src="__STATIC__/admin/js/lrtk.js" type="text/javascript"></script>
    <script src="__STATIC__/admin/assets/layer/layer.js" type="text/javascript"></script>
    <script src="__STATIC__/admin/assets/laydate/laydate.js" type="text/javascript"></script>
</head>

<body>
<div class="crumbs">
    <ul>
        <li>
            <a class="active" href="javascript:;">角色列表</a>
        </li>
    </ul>
</div>
<div class="page-content clearfix">
    <div class="administrator">
        <div class="d_Confirm_Order_style">
            <form action="{:url('rbac/administrator')}" method="post">
                <div class="search_style">
                    <ul class="search_content clearfix">
                        <li>
                            <label class="l_f">登录名名称:</label>
                            <input name="username" type="text" class="text_add" placeholder="" value="{$username}"/>
                        </li>
                        <li>
                            <label class="l_f">开启状态:</label>
                            <select name="status">
                                <option value="-1" {if condition="$status==-1"} selected {/if}>==请选择==</option>
                                <option value="1" {if condition="$status==1"} selected {/if}>==开启==</option>
                                <option value="0" {if condition="$status==0"} selected {/if}>==关闭==</option>
                            </select>
                        </li>
                        <li>
                            <label class="l_f">添加时间:</label>
                            <input name="remark" type="text" class="text_add" placeholder="" id="start"/>
                        </li>
                        <li style="width:90px;">
                            <button type="submit" class="btn_search">
                                <i class="fa fa-search"></i>查询
                            </button>
                        </li>
                    </ul>
                </div>
            </form>
            <!--操作-->
            <div class="border clearfix">
                <span class="l_f">
                    <a href="javascript:;" class="btn btn-warning"><i class="fa fa-plus"></i> 添加管理员</a>
                    <a href="javascript:;" class="btn btn-danger" id="delMultip"><i class="fa fa-trash"></i> 批量删除</a>
                </span>
            </div>
            <!--管理员列表-->
            <div class="clearfix">
                <div class="table_menu_list">
                    <form id="form1" action="{:url('rbac/deladministrator')}" method="post">
                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                            <tr>
                                <th width="25px">
                                    <label>
                                        <input type="checkbox" class="ace">
                                        <span class="lbl"></span>
                                    </label>
                                </th>
                                <th width="80px">编号</th>
                                <th width="250px">登录名</th>
                                <th width="100px">登录时间</th>
                                <th width="100px">登录IP</th>
                                <th width="180px">加入时间</th>
                                <th width="70px">状态</th>
                                <th width="200px">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        {foreach $admins as $item}
                            <tr>
                                <td>
                                    <label>
                                        <input type="checkbox" class="ace del_admin" name="admin_id[]"
                                               value="{$item.admin_id}">
                                        <span class="lbl"></span>
                                    </label>
                                </td>
                                <td>{$item.admin_id}</td>
                                <td>{$item.username}</td>
                                <td>{$item.login_time}</td>
                                <td>{$item.login_ip}</td>
                                <td>{$item.create_time}</td>
                                <td>
                                    {if condition="$item.status==1"}
                                    <span class="label label-success radius">已启用</span>
                                    {else}
                                    <span class="label label-success radius">已停用</span>
                                    {/if}
                                </td>
                                <td>
                                    <a  href="{:url('rbac/distributionrole',['admin_id'=>$item.admin_id])}" title="分配角色"
                                        class="btn btn-xs btn-success">角色</a>
                                    <a  href="{:url('rbac/resetPwd',['admin_id'=>$item.admin_id])}" title="重置密码"
                                        class="btn btn-xs btn-success">重置</a>
                                    <a title="编辑"  href="{:url('rbac/editeadministrator',['admin_id'=>$item.admin_id])}" class="btn btn-xs btn-info">
                                        <i class="fa fa-edit bigger-120"></i>
                                    </a>
                                    <a title="删除" href="javascript:;" data-id="{$item.admin_id}"   class="btn btn-xs btn-warning administrator_del">
                                        <i class="fa fa-trash  bigger-120"></i>
                                    </a>
                                </td>
                            </tr>
                        {/foreach}
                        </tbody>
                    </table>
                    </form>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="dataTables_info">共 2 条</div>
                </div>
                    <div class="col-sm-6">
                        <div class="dataTables_info">{$admins->render()}</div>
                    </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    /*确定删除*/
    /*function confirm_msg(obj) {
        var url = $(obj).attr('url');
        layer.confirm('确认要删除吗？', function(index) {
            $(obj).parents("tr").remove();
            layer.msg('已删除!', {
                icon: 1,
                time: 1000
            });
        });
    }
    $(function(){
        $('table th input:checkbox').on('click', function() {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox').each(function() {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
            });
        });
        laydate({
            elem: '#start',
            event: 'focus'
        });
    })*/
    //单行删除
    $('.administrator_del').on('click',function () {
        var that=$(this);

        layer.confirm('真的那么狠心吗?',{icon:3,title:'错误提示'},function (index) {
            del(that);
            layer.close(index);
        });
    });
    function del(that){
        var admin_id=$(that).data('id');
        var url="{:url('rbac/delAdministrator')}";
        var data={admin_id:admin_id};
        $.post(url,data,function (res) {
            if(res.status==1){
                $(that).parent().parent().remove();
                layer.msg('删除成功',{
                    title:'提示',
                    icon:6
                })
            }else{
                layer.msg('删除失败',{
                    title:'提示',
                    icon:4
                })
            }
        },'json');
    };

    //d多行删除
    $('#delMultip').on('click',function (){
        var num=0;
        $.each($('.del_admin'),function (index,item) {
            if(item.checked){
                num++;
            }
            if(num==0){
                layer.msg('您没有选择任何要删除的数据');
                return;
            }
            layer.confirm('真的那么狠心吗?',{icon:3,title:'删除提示'},function(index){
                $('#form1').submit();
            });

        })

    })
      /*用户-停用*/
            function member_stop(obj, id) {
                layer.confirm('确认要停用吗？', function(index) {
                    $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs " onClick="member_start(this,id)" href="javascript:;" title="启用"><i class="fa fa-close bigger-120"></i></a>');
                    $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已停用</span>');
                    $(obj).remove();
                    layer.msg('已停用!', {
                        icon: 5,
                        time: 1000
                    });
                });
            }
            /*用户-启用*/
            function member_start(obj, id) {
                layer.confirm('确认要启用吗？', function(index) {
                    $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs btn-success" onClick="member_stop(this,id)" href="javascript:;" title="停用"><i class="fa fa-check  bigger-120"></i></a>');
                    $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
                    $(obj).remove();
                    layer.msg('已启用!', {
                        icon: 6,
                        time: 1000
                    });
                });
            }
</script>
</body>
</html>